<%--
 *  File:    OrgGroupForPop.jsp
 *  @Author: banshang	
 *  Date:    2010/10/14
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.OrgGroupSummary");  
%>

<% //--------------------------------------  variant and initialization --%>
<%
  	String strModuleName = "OGM";
  	String strTableName = "ovorggroup";
	String privilegeCode = "all";
	String contextPath = request.getContextPath();
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>


<html>
<head>
<title>OrgGroupForPop</title>
<PageFlow:CheckPageFlow pageName="p_orggroupforpop"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
	if(totalsummary == null) totalsummary = new Vector();
%>
<script>
function clickRow(id,name){
	document.cform.orggroupid.value=id;
	document.cform.groupname.value=name;
}
function page_done(){
	var orggroupid = document.cform.orggroupid.value;
	var groupname = document.cform.groupname.value;

	opener.setOrgGroup(orggroupid,groupname);
	window.close();
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "OrgGroupForPop.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
</script>
</head>
<body>
	
	<% //--------------------------------------  hidden form variant --%>	
	<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_orggroupforpop">
    <input type="hidden" name="actionname">   
	<custom:hidden property="deptid"></custom:hidden>
    
	<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	
	<table width="100%" cellspacing="0" border="0" cellpadding="0">
	<tr>
     	<td>
     		<table width="100%" border="0" cellspacing="0">  
		        <%@ include file="/inc/SummarySearch.inc" %>
		    </table>
     	</td>
    </tr>
  	<tr> 
    	<td> 
      
      		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        	
        	<% //--------------------------------------  summary header --%>
        	<tr class="deepblue-left">
        		<td width="22" class="title_center">&nbsp;</td> 
           		<td width="100" class="title_center" ><a href="javascript:page_summary('orderby','groupcode')"><%= label.getLabelName("L_GroupCode") %></a></td>
          		<td width="120" class="title_center" ><a href="javascript:page_summary('orderby','groupname')"><%= label.getLabelName("L_GroupName") %></a></td>
          		<td width="120" class="title_center" ><a href="javascript:page_summary('orderby','deptname')"><%= label.getLabelName("L_Department") %></a></td>
          	</tr>
        
        	<%
             	int i = 0;
             	String strClassType = new String();   
             	boolean bHasChecked = false;    
             	Integer nDefaultOrgGroupId = null; 
             	String nDefaultOrgGroupName = "";
             	Integer nDefaultGrade = null;
             	String nDefaultIsBottom = "";
             	Integer nDefaultParentGroupId = null;
          	%>
          	<logic:iterate id="orggrpsum" collection="<%= totalsummary %>">     
        
        	<%
            	HashMap orggrpMap = (HashMap)pageContext.getAttribute("orggrpsum"); 
            	String strIsDisabled = new String("");
            	String strIsChecked = new String("");
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{                    
              		strClassType = "";
            	}
	            
            	if(!bHasChecked)
            	{
              		strIsChecked = "Checked";                       
              		bHasChecked = true;      
              		nDefaultOrgGroupId = (Integer)(orggrpMap.get("orggroupid"));     
              		nDefaultOrgGroupName = (String)(orggrpMap.get("groupname"));     
            	}
            	i++;   
            
            	String pgrp = (orggrpMap.get("parentgroupid")==null ? "" : (orggrpMap.get("parentgroupid")).toString());                      
          	%>
          	<tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:radiotrue('radio<%=JspHelper.filterNull(i)%>');clickRow('<custom:write property="orggroupid" name="orggrpsum"/>','<custom:write property="groupname" name="orggrpsum"/>')" class="<%=JspHelper.filterNull(strClassType)%>">
          		<td >
              		<input id="radio<%=i%>" type="radio" name="radiobutton" <%=JspHelper.filterNull( strIsDisabled )%> value=<%=JspHelper.filterNull( orggrpMap.get("orggroupid") )%> class="checkbox" <%=JspHelper.filterNull( strIsChecked)%> onClick="javascript:clickOrgGroup('<%=JspHelper.filterNull( orggrpMap.get("orggroupid") )%>', '<%=JspHelper.filterNull( orggrpMap.get("groupname") )%>', '<%=JspHelper.filterNull( orggrpMap.get("grade") )%>', '<%=JspHelper.filterNull( orggrpMap.get("isbottom") )%>', '<%=JspHelper.filterNull( pgrp )%>')">
            	</td>
            	<td>&nbsp;<%=JspHelper.filterNull( orggrpMap.get("groupcode") )%></td>
            	<td>&nbsp;<%=JspHelper.filterNull( orggrpMap.get("groupname") )%></td>
            	<td>&nbsp;<custom:write property="deptname" name="orggrpsum" nbsp="true"/></td>
          	</tr>
          	</logic:iterate> 
        	
        	<% //--------------------------------------  default value --%>       
        	<input type="hidden" name="orggroupid" value="<%=JspHelper.filterNull( nDefaultOrgGroupId )%>">
        	<input type="hidden" name="groupname" value="<%=JspHelper.filterNull( nDefaultOrgGroupName )%>">
        	 
        	
        	<% //--------------------------------------  flipping page --%>
    		<%@ include file="/inc/SummaryAction.inc" %>
    		</table>
    		
    		<% //--------------------------------------  page operation button --%>
      		<table width="100%" cellspacing="0" cellpadding="0">
        	<tr> 
          		<td class="summary_top"></td>
        	</tr>
        	<tr> 
          		<td class="td_center">
            		<a onclick="page_done()"><custom:button type="1" label="L_Ok" imgsrc="new.gif" border="0" style="width:60"/></a>
          		</td>
        	</tr>
      		</table>
    	</td>
  	</tr>
  	</table>
</form>
</body>
</html>


